package com.zzzyh.forumsystemclient.exception;

import com.zzzyh.forumsystemclient.common.AppResult;
import com.zzzyh.forumsystemclient.common.ResultCode;

/**
 * @author 郑雨杭
 * @create 2025/5/27 - 15:50
 * 统一异常返回格式
 */
public class AppException extends RuntimeException{
    private AppResult errorResult;

    public AppException(ResultCode resultCode) {
         super(resultCode.getMessage());
          this.errorResult = AppResult.failed(resultCode);
    }

    public AppResult getErrorResult() {
        return errorResult;
    }


    public AppException(AppResult errorResult) {
        super(errorResult.getMessage());
        this.errorResult = errorResult;
    }

    public AppException() {
        super();
    }

    public AppException(Throwable cause) {
        super(cause);
    }

    public AppException(String message, Throwable cause) {
        super(message, cause);
    }

    public AppException(String message) {
        super(message);
    }
}
